package com.xugou.service;

import com.xugou.dao.UserMapper;
import com.xugou.pojo.User;

/**
 * @author xugou
 * @date 2021/11/12  21:58
 */
public class UserServiceImpl implements UserService{

    private UserMapper userMapper;

    //set方法利用Spring进行注入，若有注解可以自动注入
    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    public User checkLogin(String username, String password) {
        //登录验证
        User user = userMapper.getUserByName(username);

        if (user!=null && user.getPassword().equals(password)){
            return user;
        }
        return null;
    }

    public boolean Regist(User user) {
        //传递用户信息进行注册
        int i =userMapper.registerByUserProperty(user);
        if (i>0){
            return true;
        }else{
            return false;
        }
    }

    public UserMapper getUserMapper() {
        return userMapper;
    }
}
